﻿
using Admin.NET.Application;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace Admin.NET.Web.Entry.Controllers
{
    [AllowAnonymous]
    public class FormController : Controller
    {
        private readonly SysCustomFormService _formService;
        public FormController(SysCustomFormService formService)
        {
            _formService = formService;
        }
        public IActionResult Index()
        {
            return View();
        }
        public IActionResult Add()
        {
            return View();
        }
        public IActionResult Edit()
        {
            return View();
        }
        public IActionResult Run(long id)
        {
            ViewBag.CustomForm = _formService.Get(id).Result;
            return View();
        }

        #region "可视表单"
        /// <summary>
        /// 设计
        /// </summary>
        /// <returns></returns>
        public IActionResult FormDesigner(long id)
        {
            return View();
        }
        /// <summary>
        /// 预览
        /// </summary>
        /// <returns></returns>
        public IActionResult FormPreview(long id)
        {
            return View();
        }
        /// <summary>
        /// 列表
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task<IActionResult> FormList(long id)
        {
            ViewBag.Title = "测试";
            ViewBag.Id = id;
            ViewBag.Parameter = await _formService.GetListParameter(id);

            return View();
        }
        /// <summary>
        /// 编辑
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task<IActionResult> FormEdit(long id)
        {
            ViewBag.CustomForm = await _formService.Get(id);
            return View();
        }
        #endregion
    }
}